import request from '@/utils/request'

// 分页查询供应商
export const querySupplierService = (params: { pageNumber: number; pageSize: number; supplierName: string }) => {
    return request.get('/supervisor/querySupplier', { params })
}

// 添加供应商
export const addSupplierService = (supplier: {
    supplierName: string,
    contact: string,
    supplierCount: number,
    qualifyCount: number
}) => {
    return request.post('/supervisor/addSupplier', supplier)
}

// 更新供应商
export const updateSupplierService = (supplier: {
    supplierId: number,
    supplierName: string,
    contact: string,
    supplierCount: number,
    qualifyCount: number
}) => {
    return request.put('/supervisor/updateSupplier', supplier)
}

// 删除供应商
export const deleteSupplierService = (supplierId: number) => {
    return request.delete(`/supervisor/deleteSupplier/${supplierId}`)
}

//查询供应商列表
export const supplierListService = () =>{
    return request.get('/supervisor/supplierList')
}

// ==================== 原材料订单相关API ====================

// 分页查询原材料订单
export const queryMaterialOrderService = (params: {
    pageNumber: number,
    pageSize: number,
    orderStatus?: string,
    materialName?: string,
    createTime?: string
}) => {
    return request.get('/supervisor/queryMaterialOrder', { params })
}

// 添加原材料订单
export const addMaterialOrderService = (materialOrder: {
    supplierId: number,
    materialName: string,
    materialCount: number,
    materialBatchId: string
}) => {
    return request.post('/supervisor/addMaterialOrder', materialOrder)
}

// 更新原材料订单
export const updateMaterialOrderService = (materialOrder: {
    orderId: number,
    supplierId?: number,
    materialName?: string,
    materialCount?: number,
    orderStatus?: string,
    batchNumber?: string
}) => {
    return request.put('/supervisor/updateMaterialOrder', materialOrder)
}

// 删除原材料订单
export const deleteMaterialOrderService = (orderId: number) => {
    return request.delete(`/supervisor/deleteMaterialOrder/${orderId}`)
}